package com.bdqn.service;
import com.bdqn.dao.SysRoleMapper;
import com.bdqn.pojo.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
//@Transactional
@Service("sysroleService") // 注册为一个Service层的Bean
public class SysRoleServiceImpl implements SysRoleService {
    @Autowired
    private SysRoleMapper sysRoleMapper;

    //@Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<SysRole> selectrole(SysRole sysRole) {
        try {
            return sysRoleMapper.selectrole(sysRole);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    //添加
    @Override
    public boolean insertrole(SysRole sysRole) {
        boolean result = false;
        try {
            if (sysRoleMapper.insertrole(sysRole) == 1) {
                result = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        return true;
    }

    @Override
    public int delete(Integer id) {
        try {
            return sysRoleMapper.delete(id);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public boolean update(SysRole sysRole) {
        sysRoleMapper.update(sysRole);
        return true;
    }
}
